Method and computer program product and apparatus for handling sudden power off recovery

ABSTRACT

The invention introduces a non-transitory computer program product for handling a sudden power off recovery (SPOR) to include program code to: drive a flash access interface to read pages of a current block in sequence after a power restart subsequent to a sudden power off (SPO); mark the last correct page of the current block according to page read statuses for the current block; drive the flash access interface to read protection information of pages of a temporary block in sequence, so as to mark the first incorrect page of the temporary block; and drop data of the first incorrect page and pages thereafter of the temporary block.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of priority to Patent ApplicationNo. 201910664125.7, filed in China on Jul. 23, 2019; the entirety ofwhich is incorporated herein by reference for all purposes.

BACKGROUND

The disclosure generally relates to flash memory and, more particularly,to methods and computer program products and apparatuses for handlingsudden power off recovery (SPOR).

Flash memory devices typically include NOR flash devices and NAND flashdevices. NOR flash devices are random access—a host accessing a NORflash device can provide the device any address on its address pins andimmediately retrieve data stored in that address on the device's datapins. NAND flash devices, on the other hand, are not random access butserial access. It is not possible for NAND to access any random addressin the way described above. Instead, the host has to write into thedevice a sequence of bytes which identifies both the type of commandrequested (e.g. read, write, erase, etc.) and the address to be used forthat command. The address identifies a page (the smallest chunk of flashmemory that can be written in a single operation) or a block (thesmallest chunk of flash memory that can be erased in a singleoperation), and not a single byte or word.

Data programming operations may be interrupted after a sudden power off(SPO) induced by a natural or man-made disaster. Thus, it is desirableto have methods and computer program products and apparatuses forhandling SPOR, so as to recover the interrupted data programmingoperations.

SUMMARY

In an aspect of the invention, a method for handling a sudden power offrecovery (SPOR) is performed by a processing unit when loading andexecuting relevant firmware or software code to include steps: readingpages of a current block in sequence after a power restart subsequent toa sudden power off (SPO); marking the last correct page of the currentblock according to page read statuses for the current block; readingprotection information of pages of a temporary block in sequence, so asto mark the first incorrect page of the temporary block; and droppingdata of the first incorrect page and pages thereafter of the temporaryblock. The current block is a multi-level cell (MLC) block or a triplelevel cell (TLC) block. The temporary block is a single-level cell (SLC)block. The protection information of the first incorrect page of thetemporary block includes address information pointing to a page afterthe last correct page of the current block.

In another aspect of the invention, a computer program product forhandling a SPOR is introduced to include program code when being loadedand executed by a processing unit to practice the method describedabove.

In a further aspect of the invention, an apparatus for handling a SPORis introduced to include a flash access interface and a processing unit.The processing unit is arranged to operably perform operations of themethod described above.

Both the foregoing general description and the following detaileddescription are examples and explanatory only, and are not restrictiveof the invention as claimed.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is the system architecture according to an embodiment of theinvention.

FIG. 2 is a schematic diagram depicting connections between one accesssub-interface and multiple storage sub-units according to an embodimentof the invention.

FIG. 3 is the data organization of a storage sub-unit according to anembodiment of the invention.

FIG. 4 is a schematic diagram of data block allocations in response to asudden power off recovery (SPOR) according to an embodiment of theinvention.

FIGS. 5 and 6 are schematic diagrams showing protection informationstored in a current block, a temporary block and a backup blockaccording to an embodiment of the invention.

FIG. 7 is a flowchart illustrating a method for programming data with alength shorter than a page length into an empty page of a temporaryblock according to an embodiment of the invention.

FIG. 8 is a flowchart illustrating a method for programming the wholepage of data into an empty page of a current block according to anembodiment of the invention.

FIG. 9 is a flowchart illustrating a method for marking correct pages ina SPOR process according to an embodiment of the invention.

FIG. 10 is a schematic diagram of data and protection information storedin a current block, a temporary block and a backup block according to anembodiment of the invention.

FIG. 11 is a flowchart illustrating a method for migrating data of pagesneighboring to an uncorrectable error check and correction (UECC) pagein a SPOR process according to an embodiment of the invention.

FIG. 12 is a schematic diagram showing a data migration for pagesneighboring to an UECC page according to an embodiment of the invention.

FIG. 13 is a flowchart illustrating a method for migrating data of pagesneighboring to an UECC page in a SPOR process according to an embodimentof the invention.

DETAILED DESCRIPTION

Reference is made in detail to embodiments of the invention, which areillustrated in the accompanying drawings. The same reference numbers maybe used throughout the drawings to refer to the same or like parts,components, or operations.

The present invention will be described with respect to particularembodiments and with reference to certain drawings, but the invention isnot limited thereto and is only limited by the claims. It will befurther understood that the terms “comprises,” “comprising,” “includes”and/or “including,” when used herein, specify the presence of statedfeatures, integers, steps, operations, elements, and/or components, butdo not preclude the presence or addition of one or more other features,integers, steps, operations, elements, components, and/or groupsthereof.

Use of ordinal terms such as “first”, “second”, “third”, etc., in theclaims to modify a claim element does not by itself connote anypriority, precedence, or order of one claim element over another or thetemporal order in which acts of a method are performed, but are usedmerely as labels to distinguish one claim element having a certain namefrom another element having the same name (but for use of the ordinalterm) to distinguish the claim elements.

It will be understood that when an element is referred to as being“connected” or “coupled” to another element, it can be directlyconnected or coupled to the other element or intervening elements may bepresent. In contrast, when an element is referred to as being “directlyconnected” or “directly coupled” to another element, there are nointervening elements present. Other words used to describe therelationship between elements should be interpreted in a like fashion(e.g., “between” versus “directly between,” “adjacent” versus “directlyadjacent.” etc.)

Refer to FIG. 1. The system architecture 100 may include a host 110, adevice 130 and a storage unit 150. The system architecture may bepracticed in a personal computer (PC), a laptop PC, a tablet computer, amobile phone, a digital camera, a digital recorder, or other electronicconsumer products. The device 130 may contain a processing unit 133. Thehost 110 may communicate with the device 130 through a flash memoryprotocol, such as Universal Flash Storage (UFS). A flash memorycontroller 133 is electrically connected (coupled) to the host 110through a data link (DL) layer 132 and a physical layer (PHY) 131. Theflash memory controller 133 may read user data of the storage unit 150from a data buffer (no shown in FIG. 1) by a direct memory access (DMA)controller (no shown in FIG. 1) and serially clock the user data out tothe host 110 through the DL layer 132 and the PHY 131. The flash memorycontroller 133 may write user data to be programmed into the data bufferby a DMA controller (no shown in FIG. 1). The processing unit 134 may beimplemented in numerous ways, such as with general-purpose hardware thatis programmed when loading and executing relevant software or firmwareinstructions to perform the functions recited herein, such as asingle-core processor, a multi-core processor with parallel computationcapability, a Graphical Processing Unit (GPU), a lightweightgeneral-purpose processor, or others. The flash memory controller 133may be a UFS controller to communicate with the host 110 through UFSprotocol. Although embodiments of the invention describe UFS as anexemplary communications protocol, those artisans may apply theinvention to some other communications protocols, such as UniversalSerial Bus (USB), Advanced Technology Attachment (ATA), Serial AdvancedTechnology Attachment (SATA), Peripheral Component Interconnect Express(PCI-E), etc.

The device 130 may further include a flash access interface (I/F) 139 tothereby enable the processing unit 134 to communication with the storageunit 150, specifically, using a Double Data Rate (DDR) protocol, such asOpen NAND Flash Interface (ONFI), DDR toggle, or others. The processingunit 134 writes user data into a designated address (a destinationaddress) of the storage unit 150 and reads user data from a designatedaddress (a source address) thereof through the flash access interface139. The flash access interface 139 may use several electronic signalsincluding a data line, a clock signal line and control signal lines forcoordinating command and data transfer between the processing unit 134and the storage unit 150. The data line may be used to transfercommands, addresses, read data and data to be programmed; and thecontrol signal lines may be used to transfer control signals, such asChip Enable (CE), Address Latch Enable (ALE), Command Latch Enable(CLE), Write Enable (WE), etc.

The storage unit 150 may contain multiple storage sub-units and eachstorage sub-unit may use a respective access sub-interface tocommunicate with the processing unit 134. One or more storage sub-unitsmay be packaged in a single die. The flash access interface 139 maycontain j access sub-interfaces and each access sub-interface mayconnect to i storage sub-units. Each access sub-interface and theconnected storage sub-units behind may be referred to as a I/O channelcollectively and each storage sub-unit may be identified by a LogicalUnit Number (LUN). That is, i storage sub-units may share the sameaccess sub-interface. For example, assume that the storage device 130contains 4 I/O channels and each I/O channel connects to 4 storagesub-units: The storage device 130 may access 16 storage sub-units. Theprocessing unit 134 may drive one of the access sub-interfaces to readdata from the designated storage sub-unit. Each storage sub-unit has anindependent CE control signal. That is, it is required to enable acorresponding CE control signal when attempting to perform data read orprogramming from or into a designated storage sub-unit via an associatedaccess sub-interface. It is apparent that any number of I/O channels maybe provided in the storage device 130, and each I/O channel may includeany number of storage sub-units, and the invention should not be limitedthereto. Refer to FIG. 2. The processing unit 134, through the accesssub-interface 139_0, may use independent CE control signals 230_0 to230_aAi to select one of the connected storage sub-units 150_0 to 150_i,and then read data from or program data into the designated location ofthe selected storage sub-unit via the shared data line 210.

Each storage sub-unit may include multiple data planes, each data planemay include multiple blocks and each block may include multiple pages.Refer to FIG. 3. Takes the storage sub-unit 150_0 as an example. Thestorage sub-unit 150_0 includes two data planes 310 and 330. The dataplane 310 includes blocks 310_0 to 310_m and the data plane 330 includesblocks 330_0 to 330_m. Each block includes n+1 pages. Each block may beconfigured as a single-level cell (SLC) block, a multi-level cell (MLC)block or a triple level cell (TLC) block. Each memory cell of the SLC,the MLC and the TLC blocks may store two, four and eight states,respectively. Each word line of the SLC block may store one page ofdata. Each word line of the MLC block may store two pages of data,including a most significant bit (MSB) page and a least significant bit(LSB) page. Each word line of the TLC block may store three pages ofdata, including a MSB page, a center significant bit (CSB) page and aLSB page.

Refer to FIG. 4. In the direct-write mode, a static random access memory(SRAM) 136 does not allocate cache for buffering a large number of hostwrite commands with data to be programmed, but allocates limited spaceof a command queue and a data buffer 410 for storing several host writecommands with data to be programmed. Different from the cache mode, theprocessing unit 134 under the direct-write mode completes a host writecommand after driving the flash access interface 139 to program datainto the storage unit 150 according to the host write command. To dealwith a variety of host write commands issued by the host 110, thestorage sub-unit 150_0 may allocate two blocks: a current block 451; anda temporary block 453. The current block 451 is configured as a MLC orTLC block and the temporary block 453 is configured as a SLC block.Assume that the minimum data unit managed by the host 110 is 4K bytesand a data length of each page (referred to as a page length) of thestorage sub-unit 150_0 is 16K bytes: When a host write command instructsthe device 130 to write data of one or more page lengths, the processingunit 134 drives the flash access I/F 139 to program the data into one ormore empty pages of the current block 451 in the MLC or TLC mode. When ahost write command instructs the device 130 to write data shorter thanthe page length, the processing unit 134 drives the flash access I/F 139to program the data into one or more sectors of one empty page of thetemporary block 453 in the SLC mode, where each sector stores data of 4Kbytes. Once any page of the temporary block 453 is filled with data, theprocessing unit 134 may drive the flash access I/F 139 to program dataof the whole page of the temporary block 453 into an empty page of thecurrent block 451 in the MLC or TLC mode.

Since the current block 451 is an MLC or TLC block (that is, two orthree pages of data are stored in the same word line), an occurrence ofSPO during a data programming into the current block 451 mayadditionally damage page data that has been programmed into. Forexample, refer to FIG. 3. Suppose that the block 310_0 is an MLC block(as the current block), in which the page P #0 is an LSB page of a wordline and the page P #3 is a MSB page of the same word line. The pages P#0 and P #3 may be referred to as a page pair. If a SPO happens during adata programming into the page P #3 of the block 310_0, then it probablydamages data of the page P #0 that has been programmed into. To preventthe problems as described above, refer to FIG. 4. The storage sub-unit150_0 further allocate a backup block 455 configured as a SLC block.Before programming data into a MSB page (e.g. the page P #3) of thecurrent block (e.g. the block 310_0), the processing unit 134 drives theflash access I/F 139 to store (or backup) data of a LSB pagecorresponding to this MSB page of the current block in an empty page ofthe backup block 455 first, and then, program data into this MSB page ofthe current block.

Similarly, as to the current block being a TLC block, the processingunit 134 may drive the flash access I/F 139 to store (or backup) data ofa CSB page corresponding to this MSB page of the current block in anempty page of the backup block 455 first, and then, program data intothis MSB page of the current block. Or, the processing unit 134 maydrive the flash access I/F 139 to store (or backup) data of an LSB pagecorresponding to this CSB page of the current block in an empty page ofthe backup block 455 first, and then, program data into this CSB page ofthe current block.

Those artisans may practice any of the current block 451, the temporaryblock 453 and the backup block 455 in an arbitrary data plane (e.g. thedata plane 310 or 330 as shown in FIG. 3).

To shorten the time for handling a SPOR, the processing unit 134 doesnot spend time as much as possible to reprogram data into the currentblock 451, instead, reconstructs the current block 451 by obtainingcorresponding data from the temporary block 453 and/or the backup block455. Embodiments of the invention describe ways of storing protectioninformation in spare space of each page of the current block 451, thetemporary block 453 and the backup block 455, which can be used in apossible SPOR. To maintain the order of storing page data of the currentblock 451, the temporary block 453 and the backup block 455 in time,spare space of each page of the current block 451 may record addressinformation pointing to the first empty page of the temporary block 453(for example, storing the block number of the temporary block 453 andthe page number of the first empty page thereof) at the time that thepage data of the current block 451 was programmed, and spare space ofeach page of the temporary block 453 may record address informationpointing to the first empty page of the current block 451 (for example,storing the block number of the current block 451 and the page number ofthe first empty page thereof) at the time that the page data of thetemporary block 453 was programmed. Also, since data of the CSB page orthe LSB page (referred to as a source page) of the current block 451 maybe backed up in one page (referred to as a backup page) of the backupblock 455, therefore, spare space of one or more pages of the backupblock 455 may record address information pointing to the first emptypage of the current block 451 (for example, storing the block number ofthe current block 451 and the page number of the first empty pagethereof), as well as address information pointing to the first emptypage of the temporary block 453 (for example, storing the block numberof the current block 453 and the page number of the first empty pagethereof) at the time that the page data of the backup block 455 wasprogrammed.

In some embodiments, spare space of each page of the current block 451,the temporary block 453 and the backup block 455 has capacity forstoring address information pointing to two or more pages. Refer to FIG.5 showing several use cases. Data of the N-th page of the current block451 is backed up in the O-th page of the backup block 455. The blocks inslashes as shown in FIG. 5 represent empty pages. Spare space 510 of theN-th page of the current block 451 may store address informationpointing to the (M+1)-th page of the temporary block 453. Spare space530 of the M-th page of the temporary block 453 may store addressinformation pointing to the (N+1)-th page of the current block 451.Spare space 550 a of the O-th page of the backup block 455 may storeaddress information pointing to the (N+1)-th page of the current block451 and spare space 550 b of the O-th page of the backup block 455 maystore address information pointing to the (M+1)-th page of the temporaryblock 453.

In alternative embodiments, spare space of each page of the currentblock 451, the temporary block 453 and the backup block 455 has limitedcapacity for storing address information pointing to only one page. Tocompletely record required protection information in spare space of thebackup block 455 as described above, the processing unit 134 programsdata into empty pages of the current blocks of the data plane 310 andthe data plane 330 alternately and treats the two pages of the dataplane 310 and the data plane 330 as a page group. For example, refer toFIG. 3. Assume that the block 310_1 is the current block of the dataplane 310 and the block 330_1 is the current block of the data plane330: The processing unit 134 may program data into the page P #0 of thecurrent block 310_1, the page P #0 of the current block 330_1, the pageP #1 of the current block 310_1 and the page P #1 of the current block330_1 in sequence, where the pages P #0 of the current blocks 310_1 and330_1 form a page group and the pages P #1 of the current blocks 310_1and 330_1 form another page group. Refer to FIG. 6 showing several usecases. The current block 451 a is allocated on the data plane 310 andthe current block 451 b is allocated on the data plane 330. Data of theN-th page of the current block 451 a is backed up in the O-th page ofthe backup block 455 and data of the N-th page of the current block 451b is backed up in the (O+1)-th page of the backup block 455. The blocksin slashes as shown in FIG. 6 represent empty pages. Spare space 510 aof the N-th page of the current block 451 a may store addressinformation pointing to the M-th page of the temporary block 453 andspare space 510 b of the N-th page of the current block 451 b may storenothing. Spare space 530 of the M-th page of the temporary block 453 maystore address information pointing to the (N+1)-th page of the currentblock 451. Spare space 550 a of the O-th page of the backup block 455may store address information pointing to the (N+1)-th page of thecurrent block 451 a and spare space 550 b of the (O+1)-th page of thecurrent block 455 may store address information pointing to the M-thpage of the temporary block 453.

Refer to FIG. 7. The method as shown in FIG. 7 may be performed by theprocessing unit 134 when loading and executing relevant firmware orsoftware instructions. The processing unit 134 generates protectioninformation of a temporary page, which includes address information atthe time pointing to the first empty page of the current block, (stepS730) after preparing data with a length (e.g. 4K, 8K or 12K) shorterthan a page length that is to be programmed into an empty page(typically being the first empty page) of the temporary block accordingto a host write command of a command queue (step S710). For example, theprocessing unit 134 generates protection information that is to beprogrammed into the spare space 530 of the temporary block 453 as shownin FIG. 5 or the spare space 530 a or 530 b of the temporary block 453as shown in FIG. 6. Next, the processing unit 134 drives the flashaccess I/F 139 to program the data and the protection information intothe first empty page of the temporary block (step S750).

Refer to FIG. 8. The method as shown in FIG. 8 may be performed by theprocessing unit 134 when loading and executing relevant firmware orsoftware instructions. The processing unit 134 prepares data of thewhole page that is to be programmed into an empty page (typically beingthe first empty page) of the current block according to a host writecommand of a command queue (step S810). Those artisans will realize thatthe whole page of data may include data obtained from the temporaryblock, or exclude any therefrom. Next, the processing unit 134determines whether the word line that the data is to be programmed intohas another programmed page data (step S820), for example, if the wordline has stored an LSB or CSB page data that was programmed for aprevious host write command. If the determination is negative (the “No”path of step S820), for example, the page that the data is to beprogrammed into is an LSB page, or the programmed LSB or CSB page dataof the word line is associated with the same host write command for theprepared data, the processing unit 134 generates protection informationof the current page, including address information pointing to the firstempty page of the temporary block (step S830). For example, theprocessing unit 134 generates protection information that is to beprogrammed into the spare space 510 of the current block 451 as shown inFIG. 5, or the spare space 510 a of the current block 451 a or the sparespace 510 b of the current block 451 b as shown in FIG. 6. Next, theprocessing unit 134 drives the flash access I/F 139 to program the dataand the protection information into the first empty page of the currentblock (step S840).

If the determination is positive (the “Yes” path of step S820), theprocessing unit 134 generates protection information of a backup page,including address information pointing to the first empty pages of thecurrent block and the temporary block (step S850). For example, theprocessing unit 134 generates protection information that is to beprogrammed into the spare space 550 a and 550 b of the backup block 455as shown in FIG. 5 or 6. The processing unit 134 drives the flash accessI/F 139 to program the presented data and protection information of theword line into the first empty page of the backup block (step S860).Next, the processing unit 134 executes steps S830 and S840 as describedabove.

Since the SPO may damage page data that has been programmed or is beingprogrammed, therefore, after a power restart subsequent to a SPO, theprocessing unit 134 may perform a SPOR process to mark correct data ofthe current block and the temporary block. Refer to FIG. 9. The methodas shown in FIG. 9 is performed by the processing unit 134 when loadingand executing relevant firmware or software instructions. The processingunit 134 uses the variable i to record a page number that is currentlyscanned within the current block, initialized as 0 (step S910).Following that, the processing unit 134 repeatedly executes a loop(steps S920 to S940) to find a page of the current block that is damagedresulting from the SPO. In each iteration, the processing unit 134drives the flash access I/F 139 to read the i-th page of the currentblock (step S920) and performs two determinations (steps S930 and S940).When the read page does not appear to be unrecoverable (the “No” path ofstep S930), or the read page cannot be recovered but has been backed upin the backup block (the “Yes” path of step S940 following the “Yes”path of step S930), the processing unit 134 determines that data of theread page is correct, increases the variable i by one and proceeds tofurther determinations for the next page (step S935). When the read pageappears to be unrecoverable (the “Yes” path of step S930) and does notbacked up in the backup block (the “No” path of step S940), theprocessing unit 134 determines that data of the read page is incorrectand the loop ends. The read page appearing to be unrecoverable meansthat, although the processing unit 134 uses the error check andcorrection (ECC) code of the read page, error bits appeared in the readdata cannot be fixed. The read page appearing to be unrecoverable isreferred to as an uncorrectable ECC (UECC) page. After the loop ends,the processing unit 134 uses a variable v1=i−1 to record a specificnumber of the last correct page of the current block. In other words,the i-th page and the following pages of the current block have beendamaged by the SPO. Those artisans may not implement the backupmechanism with the backup block, therefore, the determination of S940 ofthe method described above may be omitted.

Next, the processing unit 134 uses the variable j to record a pagenumber that is currently scanned within the temporary block, initializedas 0 (step S960). Following that, the processing unit 134 repeatedlyexecutes a loop (steps S970 to S980) to find correct pages of thetemporary block. In each iteration, the processing unit 134 drives theflash access I/F 139 to read the protection information of the j-th pageof the temporary block (step S970), and determines whether theprotection information points to a page after the v1-th page of thecurrent block (step S980). When the read protection information does notpoint to a page after the v1-th page of the current block, that is,points to the v1-th page of the current block or an earlier page (the“No” path of step S980), the processing unit 134 determines that theread page is correct, increases the variable j by one and proceeds to afurther determination for next page (step S975). When the readprotection information points to a page after the v1-th page of thecurrent block (the “Yes” path of step S980), the processing unit 134determines that the read page is incorrect and the loop ends. After theloop ends, the processing unit 134 uses the variable v2=j−1 to record aspecific number of the last correct page of the temporary block. Inother words, the j-th page (i.e. the first incorrect page) and thefollowing pages of the temporary block have temporary data that cannotbe used after the SPO.

In an aspect, embodiments of the invention introduce process stepsperformed by the processing unit 134 of the apparatus 130 when loadingand executing relevant program code: driving the flash access I/F 139 toread pages of the current block 451 in sequence after a power restartsubsequent to a SPO; marking the last correct page of the current block451 according to page read statuses for the current block 451; drivingthe flash access I/F 139 to read protection information of pages of thetemporary block 453 in sequence, so as to mark the first incorrect pageof the temporary block 453 whose protection information includes addressinformation pointing to a page after the last correct page of thecurrent block 451; and dropping data of the first incorrect page andpages thereafter of the temporary block 453. In a SPOR process, withdroppings of all the pages that were stored later than that of the lastcorrect page of the current block 451 with references made to theprotection information of the temporary block 453, it ensures the timeorder of recovered pages of the current block 451 and the temporaryblock 453 and avoids any unrecovered page is presented between recoveredcorrect pages in time.

Refer to use cases as shown in FIG. 10. Assume that the current block451 a is allocated on the data plane 310, the current block 451 b isallocated on the data plane 330, the (Q+1)-th page of the current block451 a is also stored in the P-th page of the backup block 455, the(Q+1)-th page of the current block 451 b is also stored in the (P+1)-thpage of the backup block 455, protection information 1030 of the R-thpage of the temporary block 453 points to the (Q+3)-th page of thecurrent blocks 451 a and 451 b, protection information 1031 of the(R+1)-th page of the temporary block 453 points to the (Q+4)-th page ofthe current blocks 451 a and 451 b: When detecting that the (Q+1)-thpage of the current blocks 451 a and 451 b is an UECC page (the “Yes”path of step S930) and has been backed up in the temporary block 455(the “Yes” path of step S940), the processing unit 134 replaces the dataof the (Q+1)-th pages of the current blocks 451 a and 451 b with thedata of the P-th page and the (P+1)-th page of the temporary block 455,respectively, and continues the next scanning. When detecting that the(Q+4)-th page of the current blocks 451 a and 451 b is an UECC page (the“Yes” path of step S930) and hasn't been backed up in the temporaryblock 455 (the “No” path of step S940), the processing unit 134determines that the last correct pages of the current blocks 451 a and451 b are the (Q+3)-th pages thereof (step S950).

Moreover, when detecting that protection information of the (R+1)-thpage of the temporary block 453 points to a page after the last correctpages of the current blocks 451 a and 451 b (the “Yes” path of stepS980), the processing unit 134 the last correct page of the temporaryblock 453 is the R-th page thereof (step S990).

Although data of the pages before the detected UECC page is all correct,the data retention of memory cells of physical wordlines and pagesneighboring to the UECC page may be degraded, for example, availabletimes that data thereon can be regularly read out are decreased, when anSPO occurs. Refer to FIG. 11 showing a method that is performed by theprocessing unit 134 when loading and executing relevant firmware orsoftware instructions. The processing unit 134 drives the flash accessI/F 139 to duplicate data of the last correct page and its previous t−1pages of the current block in empty pages of the temporary block (stepS1110). t may be set to an arbitrary integer ranging from 2 to 5depending on different system requirements. Next, the processing unit134 may configure t pages after the UECC page of the current block asdummy pages (step S1130). In some embodiments, the processing unit 134may drive the flash access I/F 139 to fill t pages after the detectedUECC page of the current block with dummy values, for example, “0xFF”.Next, the processing unit 134 drives the flash access I/F 139 to programdata stored in the temporary block into empty pages of a new currentblock, or empty pages after the last dummy page of this current block(step S1150).

Refer to FIG. 12 following the use cases as shown in FIG. 10. Data andprotection information 1011 a to 1013 b of the (Q+1)-th to the (Q+3)-thpages of the current blocks 451 a and 451 b are duplicated andprogrammed into the (Q+8)-th to the (Q+10)-th pages of the currentblocks 451 a and 451 b (steps S1110 and S1150). The (Q+5)-th to the(Q+7)-th pages of the current blocks 451 a and 451 b are configured asdummy pages (step S1130).

However, two or more SPOs may be occurred during data programming forthe same current block, resulting in page data that has been moved to bemistakenly determined as correct page data. To address theaforementioned problems, a validity field is inserted into each recordof a Flash-to-Host (F2H) table of the SRAM 136, which is associated withthe current block, to indicate whether data of a specific page of thecurrent block is valid. Moreover, the method as shown in FIG. 11 may bemodified with that of FIG. 13. After configuring dummy pages of thecurrent block and migrating data of candidate pages to empty pages afterthe last dummy page of the current block successfully (steps S1300,S1130 and S1310), the validity fields of the records of the F2H table,which are associated with the moved pages, the UECC page and the dummypages of the current block, are set to invalid (step S1330). Forexample, with references made to FIG. 12, validity fields of the recordsof the F2H table, which are associated with the (Q+1)-th to the (Q+7)-thpages of the current blocks 451 a and 451 b, are set to invalid. Thoseartisans will realize that the host 110 may issue erase commands to theprocessing unit 134 to erase data of specific logical address(es). Afteraddress translations, the processing unit 134 knows which sector(s) of aspecific page of the current block the logical address(es) maps to. Whendata of all sectors of a page of the current block is removed to respondto host erase command(s), the processing unit 134 may set the validityfield of the record of the F2H table, which is associated with theremoved page, to invalid.

Moreover, step S1110 of FIG. 11 is modified with step S1300 of FIG. 13,in which the processing unit 134 examines the validities of the lastcorrect page and its previous t−1 pages of the current block. If thelast correct page and its previous t−1 pages of the current block areinvalid pages, then the processing unit 134 does not perform themigration operations of steps S1310 and S1330. In other words, the lastcorrect page and its previous t−1 pages of the current block recited instep S1330 are all valid.

Although the embodiments describe the quantities of the migrated pagesand the dummy pages are the same, those artisans may set the quantity ofthe migrated pages to be different from the quantity of the dummy pages.For example, a total amount of the migrated pages is n2 and a totalamount of the dummy pages is n1, where any of n1 and n2 is an arbitraryinteger ranging from 2 to 5.

Process steps as shown in FIGS. 7-9, 11 and 13 that are executed by theprocessing unit 134 may be practiced by computer program productscomposed of one or more function modules. The function modules arestored in nonvolatile storage device and can be loaded and executed bythe processing unit 134 at relevant times. Some or all of theaforementioned embodiments of the method of the invention may beimplemented in a computer program such as a driver or a firmware programfor a dedicated hardware, or a software application program. Other typesof programs may also be suitable, as previously explained. Since theimplementation of the various embodiments of the present invention intoa computer program can be achieved by the skilled person using hisroutine skills, such an implementation will not be discussed for reasonsof brevity. The computer program implementing some or more embodimentsof the method of the present invention may be stored on a suitablecomputer-readable data carrier such as a DVD, CD-ROM, USB stick, a harddisk, which may be located in a network server accessible via a networksuch as the Internet, or any other suitable carrier.

The computer program may be advantageously stored on computationequipment, such as a computer, a notebook computer, a tablet PC, amobile phone, a digital camera, a consumer electronic equipment, orothers, such that the user of the computation equipment benefits fromthe aforementioned embodiments of methods implemented by the computerprogram when running on the computation equipment. Such the computationequipment may be connected to peripheral devices for registering useractions such as a computer mouse, a keyboard, a touch-sensitive screenor pad and so on.

Although the embodiment has been described as having specific elementsin FIGS. 1, 2 and 4, it should be noted that additional elements may beincluded to achieve better performance without departing from the spiritof the invention. Each element of FIGS. 1, 2 and 4 is composed ofvarious circuits and arranged to operably perform the aforementionedoperations. While the process flows described in FIGS. 7-9, 11 and 13include a number of operations that appear to occur in a specific order,it should be apparent that these processes can include more or feweroperations, which can be executed serially or in parallel (e.g., usingparallel processors or a multi-threading environment).

While the invention has been described by way of example and in terms ofthe preferred embodiments, it should be understood that the invention isnot limited to the disclosed embodiments. On the contrary, it isintended to cover various modifications and similar arrangements (aswould be apparent to those skilled in the art). Therefore, the scope ofthe appended claims should be accorded the broadest interpretation so asto encompass all such modifications and similar arrangements.

What is claimed is:
 1. A non-transitory computer program product forhandling a sudden power off recovery (SPOR) when executed by aprocessing unit of a device, the non-transitory computer program productcomprising program code to: drive a flash access interface to read pagesof a current block in sequence after a power restart subsequent to asudden power off (SPO), wherein the current block is a multi-level cell(MLC) block or a triple level cell (TLC) block; mark a last correct pageof the current block according to page read statuses for the currentblock; drive the flash access interface to read protection informationof pages of a temporary block in sequence, so as to mark a firstincorrect page of the temporary block, wherein the temporary block is asingle-level cell (SLC) block and the protection information of thefirst incorrect page of the temporary block comprises addressinformation pointing to a page after the last correct page of thecurrent block; and drop data of the first incorrect page and pagesthereafter of the temporary block.
 2. The non-transitory computerprogram product of claim 1, comprising program code to: generateprotection information of a page of the temporary block comprisingaddress information at the time pointing to the first empty page of thecurrent block before a SPO; and drive the flash access interface toprogram data with a length shorter than a page length, and theprotection information into the first empty page of the temporary block.3. The non-transitory computer program product of claim 1, wherein thenext page of the last correct page of the current block is anuncorrectable error check and correction (UECC) page.
 4. Thenon-transitory computer program product of claim 1, comprising programcode to: replace data of a page of the current block with data of a pageof a backup block when detecting that the page of the current block isan uncorrectable error check and correction (UECC) page and has beenbacked up in the page of the backup block, wherein the backup block is aSLC block.
 5. The non-transitory computer program product of claim 4,wherein the next page of the last correct page of the current block isan UECC page and data of the next page of the last correct page of thecurrent block hasn't been stored in the backup block.
 6. Thenon-transitory computer program product of claim 4, wherein the page ofthe current block is a most significant bit (MSB) page or a centersignificant bit (CSB) page.
 7. The non-transitory computer programproduct of claim 1, comprising program code to: configure a specificnumber t of pages after the next page of the last correct page of thecurrent block as dummy pages; and drive the flash access interface tostore data of the last correct page of the current block and itsprevious t−1 pages of the current block in empty pages of a new currentblock or empty pages after the last dummy page of the current block. 8.The non-transitory computer program product of claim 7, wherein thespecific number is an integer ranging from 2 to
 5. 9. A method forhandling a sudden power off recovery (SPOR), performed by a processingunit of a device, comprising: reading pages of a current block insequence after a power restart subsequent to a sudden power off (SPO),wherein the current block is a multi-level cell (MLC) block or a triplelevel cell (TLC) block; marking a last correct page of the current blockaccording to page read statuses for the current block; readingprotection information of pages of a temporary block in sequence, so asto mark a first incorrect page of the temporary block, wherein thetemporary block is a single-level cell (SLC) block and the protectioninformation of the first incorrect page of the temporary block comprisesaddress information pointing to a page after the last correct page ofthe current block; and dropping data of the first incorrect page andpages thereafter of the temporary block.
 10. The method of claim 9,comprising: generating protection information of a page of the temporaryblock comprising address information at the time pointing to the firstempty page of the current block before a SPO; and programming data witha length shorter than a page length, and the protection information intothe first empty page of the temporary block.
 11. The method of claim 9,comprising: replacing data of a page of the current block with data of apage of a backup block when detecting that the page of the current blockis an uncorrectable error check and correction (UECC) page and has beenbacked up in the page of the backup block, wherein the backup block is aSLC block.
 12. The method of claim 9, comprising: configuring a specificnumber t of pages after the next page of the last correct page of thecurrent block as dummy pages; and storing data of the last correct pageof the current block and its previous t−1 pages of the current block inempty pages of a new current block or empty pages after the last dummypage of the current block.
 13. An apparatus for handling a sudden poweroff recovery (SPOR), comprising: a flash access interface; and aprocessing unit, coupled to the flash access interface, arranged tooperably drive the flash access interface to read pages of a currentblock in sequence after a power restart subsequent to a sudden power off(SPO), wherein the current block is a multi-level cell (MLC) block or atriple level cell (TLC) block; mark a last correct page of the currentblock according to page read statuses for the current block; drive theflash access interface to read protection information of pages of atemporary block in sequence, so as to mark a first incorrect page of thetemporary block, wherein the temporary block is a single-level cell(SLC) block and the protection information of the first incorrect pageof the temporary block comprises address information pointing to a pageafter the last correct page of the current block; and drop data of thefirst incorrect page and pages thereafter of the temporary block. 14.The apparatus of claim 13, wherein the processing unit is arranged tooperably generate protection information of a page of the temporaryblock comprising address information at the time pointing to the firstempty page of the current block before a SPO; and drive the flash accessinterface to program data with a length shorter than a page length, andthe protection information into the first empty page of the temporaryblock.
 15. The apparatus of claim 13, wherein the next page of the lastcorrect page of the current block is an uncorrectable error check andcorrection (UECC) page.
 16. The apparatus of claim 13, wherein theprocessing unit is arranged to operably replace data of a page of thecurrent block with data of a page of a backup block when detecting thatthe page of the current block is an uncorrectable error check andcorrection (UECC) page and has been backed up in the page of the backupblock, wherein the backup block is a SLC block.
 17. The apparatus ofclaim 16, wherein the next page of the last correct page of the currentblock is an UECC page and data of the next page of the last correct pageof the current block hasn't been stored in the backup block.
 18. Theapparatus of claim 16, wherein the page of the current block is a mostsignificant bit (MSB) page or a center significant bit (CSB) page. 19.The apparatus of claim 13, wherein the processing unit is arranged tooperably configure a specific number t of pages after the next page ofthe last correct page of the current block as dummy pages; and drive theflash access interface to store data of the last correct page of thecurrent block and its previous t−1 pages of the current block in emptypages of a new current block or empty pages after the last dummy page ofthe current block.
 20. The apparatus of claim 19, wherein the specificnumber is an integer ranging from 2 to 5.